<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style></style>
  </head>
  <body>
    <div id="app">
      <p>欢迎光临_vue开发的收银系统_水果店</p>
      <p>苹果10￥/斤,折扣<8 折 ></p>
      <p>请输入要购买的斤数<input type="number" v-model="shuliang1" /></p>
      <p><button @click="txt">结账买单~</button></p>
      <p>
        结账单:总价{{shuliang2}}￥元 折扣价:{{shuliang3}}￥元
        省了:{{shuliang4}}￥元
      </p>
    </div>
    <script src="../vue.js"></script>
    <script>
      const app = new Vue({
        el: "#app",
        //定义属性
        data: {
          shuliang1: 0,
          shuliang2: 0,
          shuliang3: 0,
          shuliang4: 0,
        },
        //定义方法
        methods: {
          txt() {
            this.shuliang2 = 10 * this.shuliang1;
            this.shuliang3 = 8 * this.shuliang1;
            this.shuliang4 = this.shuliang2 - this.shuliang3;
          },
        },
      });
    </script>
  </body>
</html>
